﻿using System;

namespace ASmile.ORM.Entitys
{
    /// <summary>
    /// 实体类属性特性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
    public class EntityAttribute : Attribute
    {
        public EntityAttribute() { }

        public EntityAttribute(string colName, int colIndex, bool isNotNull = false)
        {
            ColumnName = colName;
            ColumnIndex = colIndex;
            IsNotNull = isNotNull;
        }
        public EntityAttribute(int colIndex, bool isNotNull = false)
        {
            //ColumnName = colName;
            ColumnIndex = colIndex;
            IsNotNull = isNotNull;
        }
        /// <summary>
        /// 是否主键
        /// </summary>
        public bool IsPrimaryKey { set; get; }
        /// <summary>
        /// 主键是否自动增长
        /// </summary>
        public bool IsIdentity { set; get; }
        /// <summary>
        /// 是否非空字段
        /// </summary>
        public bool IsNotNull { set; get; }
        /// <summary>
        /// 列名
        /// </summary>
        public string ColumnName { set; get; }
        /// <summary>
        /// 默认false为字段属性,如果为true则表示不是一个字段
        /// </summary>
        public bool IsNotField { set; get; }
        /// <summary>
        /// 列索引，BulkCopy 需要按列顺序生成
        /// </summary>
        public int ColumnIndex { set; get; }
    }

    /// <summary>
    /// 实体类特性
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public class EntityClassAttribute : Attribute
    {
        public EntityClassAttribute() { }

        public EntityClassAttribute(string tbName) 
        {
            TableName = tbName;
        }

        public string TableName { set; get; }
    }
}
